﻿'Copyright © Etheral Studios 2012
'File created by Nick nick@etheralstudios.com
'File has been edited by:
'Nick nick@etheralstudios.com

Public Class EditContact

    Private Sub Save_Click(sender As System.Object, e As System.EventArgs) Handles Save.Click
        Dim myStreamWriter As System.IO.StreamWriter
        Dim values As String = FirstName.Text + "," + LastName.Text + "," + IP.Text
        myStreamWriter = System.IO.File.CreateText("C:\ProgramData\WiN\Contacts\" + FirstName.Text + LastName.Text + ".csv")
        myStreamWriter.Write(values)
        myStreamWriter.Flush()
        myStreamWriter.Dispose()
        Me.Close()
    End Sub

    Private Sub EditContact_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Dim Open As New OpenFileDialog()
        Open.Filter = "Comma Seperated Values File|*.csv"
        Open.InitialDirectory = "C:\ProgramData\WiN\Contacts"
        Open.CheckFileExists = True
        Open.ShowDialog(Me)
        Try
            Open.OpenFile()
            Process.Start("notepad.exe " + Open.FileName())
            Dim src_read() As String = IO.File.ReadAllLines(Open.FileName)
            Dim firstLine As String = src_read(0)
            Dim data() As String = firstLine.Split(",")

            Dim FirstName As String = data(0)
            Dim LastName As String = data(1)
            Shell("notepad.exe C:\ProgramData\WiN\Contacts\" + FirstName + LastName + ".csv")

            Open.Dispose()
            Open.Reset()

        Catch ex As Exception
        End Try
    End Sub
End Class